package com.yskj.mwk.utils;

public class JsonResult<T> {
    private T data;
    private Object code;
    private Object msg;

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Object getCode() {
        return code;
    }

    public void setCode(Object code) {
        this.code = code;
    }

    public Object getMsg() {
        return msg;
    }

    public void setMsg(Object msg) {
        this.msg = msg;
    }

    public JsonResult(Object code, Object msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    /**
     * 若没有数据返回，默认状态码为 0，提示信息为“操作成功！”
     */
    public JsonResult() {
        this.code = 0;
        this.msg = "操作成功！";
    }

    /**
     * 若没有数据返回，可以人为指定状态码和提示信息
     */
    public JsonResult(Object code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 操作成功，返回枚举类中normal_return的状态码和状态信息，data为数据部分
     * @param data
     */
    public JsonResult(T data) {
        this.data = data;
        this.code = 0;
        this.msg = "success";
    }
}
